home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / mac / sftkisrc.hqx / SoftKiss.src.1.8 / driver_shell / driver_shell.c < prev    next >
C/C++ Source or Header  |  1992-06-28  |  2KB  |  104 lines

  1. /*
  2.  * driver_shell - code for dynamicly installing a driver
  3.  * at runtime
  4.  * SoftKiss
  5.  * by Aaron Wohl / N3LIW (aw0g+@andrew.cmu.edu) jul 1990
  6.  * 6393 Penn Ave #303
  7.  * Pittsburgh PA, 15206
  8.  * work: (412)-268-5032
  9.  * home: (412)-731-6159
  10.  */
  11.  
  12. typedef char **Handle;
  13. typedef long ResType;
  14.  
  15. #include <SysEqu.h>
  16. #include "driver_shell.h"
  17.  
  18. void main()
  19. {
  20.       asm {
  21. @drvrFlags    dc.w 0
  22. @drvrDelay    dc.w 0
  23. @drvrEMask    dc.w 0
  24. @drvrMenu    dc.w 0
  25.  
  26. @drvrOpen    dc.w @open_entry+8
  27. @drvrPrime    dc.w @prime_entry+10
  28. @drvrCtl    dc.w @ctl_entry+12
  29. @drvrStatus    dc.w @status_entry+14
  30. @drvrClose    dc.w @close_entry+16
  31.  
  32. /*drvrname,call_me,a4a5, and extra arg are patched when we are installed*/
  33. @drvrName                /*space for 48char name*/
  34.     dc.l 0,0,0,0
  35.     dc.l 0,0,0,0
  36.     dc.l 0,0,0,0
  37.  
  38. @call_me
  39.     dc.l 'call'            /*routine to call*/
  40. @a4a5
  41.     dc.l 'iba4','iba5'    /*values to load into a4 and a5*/
  42. @extra_arg
  43.     dc.l    'more'        /*extra arg for call_me to tell which driver this is*/
  44. /*8 bytes reserved for future expansion*/
  45.     dc.l 0,0
  46.  
  47. @strip_pc
  48. //    dc.w 0xA9FF        /*debugger trap*/
  49.     move.l Lo3Bytes,d0
  50.     and.l d0,(sp)
  51.     rts
  52.  
  53. @prime_entry
  54.     moveq.l #sh_PRIME,d0
  55.     bra.s @pr_ct_st_common
  56. @ctl_entry
  57.     moveq.l #sh_CONTROL,d0
  58.     bra.s @pr_ct_st_common
  59. @status_entry    
  60.     moveq.l #sh_STATUS,d0
  61.  
  62. @pr_ct_st_common
  63.     jsr @call_callme
  64.     cmpi.w #1,d0        /*still going on?*/
  65.     beq.s @ct_not_done
  66.     move.w d0,16(a0)    /*done so set error code*/
  67.     btst #1,6(a0)        /*immediate? check ioTrap*/
  68.     bne.s @ct_com_exit    /*yes so normal exit*/
  69.     move.l JIODone,-(a7) /*not immidiate and are done*/
  70.     rts
  71.  
  72. @ct_not_done
  73.     move.w #0,d0        /*still working on it*/
  74. @ct_com_exit
  75.     rts
  76.  
  77. @open_entry
  78.     moveq.l #sh_OPEN,d0
  79.     bra.s @call_set_result
  80.  
  81. @close_entry    
  82.     moveq.l #sh_CLOSE,d0
  83.  
  84. @call_set_result
  85.     jsr @call_callme
  86.     move.w d0,16(a0)    /*done so set error code*/
  87.     rts
  88.  
  89. @call_callme
  90.      movem.l a0/a1/a4-a5,-(a7) /*save volitiles and global ptrs*/
  91.       movem.l @a4a5,a4/a5    /*setup users global regs*/
  92.       move.l @extra_arg,-(a7)
  93.     move.w d0,-(a7)
  94.     move.l a1,-(a7)        /*dce*/
  95.     move.l a0,-(a7)        /*iopb*/
  96.     move.w #1,16(a0)    /*set io block busy*/
  97.     move.l @call_me,a1    /*call user driver code*/
  98.     jsr    @strip_pc
  99.     jsr (a1)
  100.     add #14,a7
  101.     movem.l (a7)+,a0/a1/a4-a5
  102.     } /*run into 'free' rts compiler gives us*/
  103. }
  104.